<template>
  <el-container style="height: 920px; border: 1px solid #eee">
    <el-aside style="background-color: rgb(238, 241, 246)" width="200px">
      <el-menu :default-active="this.$route.path" router>
        <el-submenu v-for="(menus,index) in $router.options.routes" v-if="menus.right" :index="index">
          <template slot="title" ><i class="el-icon-setting" ></i>{{ menus.name }}</template>
          <el-menu-item v-for="(menu,index1) in menus.children" v-if="menu.right" :index="menu.path">{{ menu.name }}</el-menu-item>
        </el-submenu>
      </el-menu>
    </el-aside>

    <el-container>
      <el-header style="text-align: right; font-size: 12px">
        <el-tag type="info">{{ this.$store.state.user.name }}</el-tag>
        <el-tag type="info" @click="logout">退出</el-tag>
      </el-header>

      <el-main>
        <router-view></router-view>
      </el-main>

    </el-container>
  </el-container>
</template>

<script>
export default {
  name: "index",
  typeid:null,
  created() {
    this.typeid=this.$store.state.user.typeid;
    for (var menus of this.$router.options.routes) {
      menus.right=menus.show.includes(this.typeid);
      if(menus.children!=undefined){
        for (var menu of menus.children) {
          menu.right=menu.show.includes(this.typeid);
        }
      }
    }
  },methods:{
    logout(){
      this.$router.push('/');
      this.$store.commit('REMOVE_INFO');
    }
  }
}
</script>

<style scoped>

</style>